class B(object):
    def __new__(cls):
        int("B __new__ called")
        return super().__new__(cls)

    def __init__(self):
        print("B __init__ called")
        self.attr='B'

    def test(self):
        print("B test")

class C(object):
    def __new__(cls):
        print("C __new__ called")
        return super().__new__(B)

    def __int__(self):
        print("C __init__ called")
        self.attr="C"

    def test(self):
        print("C test")

c = C() # C的__new_方法被调用 返回了一个没有被 __init__ 的 B实例
c.test() # B test 因为是B实例，所以可以调用 test()方法
print(c.attr) # 因为没有被__init_所以没有attr属性

# 输出如下：
# C __new__ called # C的__new_方法被调用
# B test
# Traceback (most recent call last):
#   File "C:\Users\s3056\Desktop\print-knowledge\Background\Python\demos\class_02.py", line 26, in <module>
#     print(c.attr)
# AttributeError: 'B' object has no attribute 'attr'

